<?php

	header("Content-Type: text/html;charset=utf-8");

	include("../_judge.php");

	include("../../function/function.php");

	

	$keys = chkstr(trim($_REQUEST['keys']));

	$user_leader = chkstr(trim($_REQUEST['user_leader']));

	$records = chkstr(trim($_REQUEST['records']));

	$page = chkstr(trim($_REQUEST['page']));

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title><?= $adminweb_titles ?></title>

<link href="../css/style.css" rel="stylesheet" type="text/css" />

<script>if (top.location != parent.location||self.location==top.location){top.location.replace('../login/admin.php')}</script>

<script language="javascript" src="../script/jquery-1.7.2.min.js"></script>

<script language="javascript" src="../script/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript" src="../script/weebox/bgiframe.js"></script>

<script type="text/javascript" src="../script/weebox/weebox.js"></script>

<link type="text/css" rel="stylesheet" href="../script/weebox/weebox.css" />

<script language="javascript">

$(document).ready(function(){

	$(".orderwin").click(function(){

		Nids=$(this).attr("msg")

		$.weeboxs.open("newsorderm.php?id="+Nids+"&rnds="+ Math.random(),{

			title: '会员详情',

			contentType:'ajax',

			width:500,

			height:300,

			//contentType:'iframe',

			showButton:false,

			modal: true,

			draggable: true

			

		});

	});



	$("#ckall").click(function(){

		if(this.checked){

			$("input[name='newsid[]']").attr('checked', true)  

		}else{   

			$("input[name='newsid[]']").attr('checked', false)  

		}   

	});

	

});

	function del(){

		if (!confirm("您确定要执行此操作吗？")) return false;

	}

</script>

</head>



<body>



<table width="97%" border="0" align="center" cellpadding="5" cellspacing="0">

  <tr>

    <td><strong>后台管理</strong>&nbsp;-&nbsp;<span class="hong"><strong>会员管理</strong></span></td>

  </tr>

</table>

<form action="newsmanage.php" method="get" name="searchForm" id="searchForm">

<table width="97%" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#336699">

  <tr>

    <td><span class="bai12">搜索：</span>

      <input name="keys" type="text" id="keys" value="<?= $keys ?>" />

      <select name="user_leader">

        <option value=""<? if($user_leader == ""){ echo " selected";}?>>选择用户类型</option>

        <option value="0"<? if($user_leader == "0"){ echo " selected";}?>>会员</option>

        <option value="1"<? if($user_leader == "1"){ echo " selected";}?>>领队</option>
        
        <option value="2"<? if($user_leader == "2"){ echo " selected";}?>>CVA</option>
		
		<option value="3"<? if($user_leader == "3"){ echo " selected";}?>>推介人</option>
      </select>

      <input type="submit" name="ss" value="搜 索" class="button2" /></td>

    <td align="right"><span class="bai12">每页显示：</span>

      <input name="records" type="text" id="records" value="<?php if(strlen($records)>0){echo $records;}else{echo "20";} ?>" size="10" onblur="this.value=this.value.replace(/\D/g,'')" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" />

      <span class="bai12">条</span></td>

  </tr>

</table>

</form>

<br />

<form action="newsaddsave.php?action=del" method="post" name="myform" id="myform">

<table width="97%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">

  <tr bgcolor="#336699">

    <td width="40" height="25" align="center"><span class="bai12">选定</span></td>

    <td align="center"><span class="bai12">用户类型</span></td>

    <td align="center"><span class="bai12">邮箱</span></td>

    <td align="center"><span class="bai12">姓名</span></td>

    <td align="center"><span class="bai12">身份证号</span></td>

    <td align="center"><span class="bai12">手机</span></td>

    <td align="center"><span class="bai12">性别</span></td>

    <td align="center"><span class="bai12">昵称</span></td>

    <td align="center"><span class="bai12">真实姓名</span></td>

    <td align="center"><span class="bai12">徒步公里数</span></td>

    <td align="center"><span class="bai12">活动次数</span></td>
    
    <td align="center"><span class="bai12">推介人</span></td>

    <td width="150" align="center"><span class="bai12">注册时间</span></td>

    <td width="70" align="center"><span class="bai12">管理</span></td>

  </tr>

  

  <?php
		
		$SQL = "";

		if(!empty($keys)){

			if(!empty($SQL)){

				$SQL = $SQL." and user_email like '%".$keys."%' or  user_phone like '%".$keys."%' or user_nickname like '%".$keys."%' ";

			}else{

				$SQL = " user_email like '%".$keys."%' or  user_phone like '%".$keys."%'  or user_nickname like '%".$keys."%' ";

			}

		}
		if($user_leader !=""){

			if(!empty($SQL)){
				if($user_leader == 2){
					$SQL = $SQL ." and user_style=1";
				}else if($user_leader == 3){
					$SQL = "user_pid='$keys'";
				}else{
					$SQL = $SQL ." and user_leader=$user_leader";
				}
			}else{
				if($user_leader == 2){
					$SQL = " user_style=1";
				}else if($user_leader == 3){
					$SQL = " user_pid!=0";
				}else{
					$SQL = " user_leader=$user_leader";

				}
			}

		}

		

		

		

		



		if(strlen($records)>0){

			$pagesize = $records; //分页数量

		}else{

			$pagesize = 20; //分页数量

		}

		

		if(strlen($page) > 0){

			$pageval = $page;

			if($pageval <= 0){

				$pageval = 1;

			}

			$page = ($pageval-1)*$pagesize;

			$page .= ",";

		}

		//分页链接地址

		$url="newsmanage.php?user_leader=$user_leader&";



		if(empty($SQL)){

			$numsql = "select * from kboy_user order by uid desc";

		}else{

			$numsql = "select * from kboy_user where ".$SQL." order by uid desc";

		}


		$news_sql = $numsql." limit $page $pagesize";

		$news_nums = mysql_num_rows(mysql_query($numsql));

		$pagecount = ceil($news_nums / $pagesize);

		$news_rows = mysql_query($news_sql);

		$i = 1;

		while($news_rs = mysql_fetch_array($news_rows)){

?>

		  <tr bgcolor="#efefef" onMouseOver="this.style.background='#C9C9C9'" onMouseOut="this.style.background='#efefef'">

			<td height="25" align="center"><input type="checkbox" name="newsid[]" id="newsid" value="<?=$news_rs['uid'] ?>" /></td>

			<td align="center">

			 <?php

			 		if($news_rs['user_leader'] == 1){

						echo "<span style='color:#009900'>领队</font>";

					}else if($news_rs['user_style'] == 1){

						echo "<span style='color:red'>CVA会员</font>";

					}else{

						echo "普通用户";

					}

			 ?>		    </td>

			<td align="center"><?=$news_rs['user_email']?>

			<?php

			 		if($news_rs['user_tui'] == 1){

						echo "<span style='color:#009900'>[推]</font>";

					}

			?>			</td>

			<td align="center"><?=$news_rs['user_realname']?></td>

			<td align="center"><?=$news_rs['user_idcard']?></td>

			<td align="center" <?php if($news_rs['user_hei'] == 1){echo 'style="text-decoration: line-through;color: red;"';} ?>><?=$news_rs['user_phone']?></td>

			<td align="center">

			<?php

					if($news_rs['user_sex'] == 1){

						echo "男";

					}elseif($news_rs['user_sex'] == 0){

						echo "女";

					}else{

						echo "保密";

					}

			?>			</td>

			<td align="center" <?php if($news_rs['user_hei'] == 1){echo 'style="text-decoration: line-through;color: red;"';} ?> ><?=$news_rs['user_nickname']?></td>

			<td align="center" <?php if($news_rs['user_hei'] == 1){echo 'style="text-decoration: line-through;color: red;"';} ?>><?=$news_rs['user_realname']?></td>

			<td align="center"><?=$news_rs['user_km']?></td>

			<td align="center"><?=$news_rs['user_activetime']?></td>
			
			<td align="center"><?php if($news_rs['user_pid'] == 0){echo "无";}else{echo getClassName("kboy_user","user_nickname","uid=".$news_rs['user_pid'])."  ID:".$news_rs['user_pid'];}?></td>

			<td align="center">

			<?=$news_rs['user_regtime']?>			</td>

			<td align="center">

			<a href="newsaddsave.php?action=resetpwd&id=<?=$news_rs['uid']?>">置密</a>&nbsp;|&nbsp;<a href="javascript:void(0);" msg="<?=$news_rs['uid']?>" class="orderwin">查看</a></td>

		  </tr>

			<?php

		}// while结束

		

		if($news_nums > 0){

			?>

		  <tr bgcolor="#efefef">

			<td height="25" colspan="13">&nbsp;

			  <input type="checkbox" name="ckall" value="ckall" id="ckall" />

			  &nbsp;全选&nbsp;

			  <select name="news_option" id="news_option">

				<option value="">请选择操作</option>

				<option value="del">删除</option>

				<option value="isheader">领队</option>

				<option value="noheader">取消领队</option>

				<option value="cvaheader">CVA会员</option>
				
				<option value="nocva">取消CVA会员</option>
				
				<option value="istui">推荐</option>

				<option value="notui">取消推荐</option>
				
				<option value="ishei">拉黑</option>

			  </select>

			  &nbsp;

			  <input type="submit" name="submit2" value="执行" onClick="return del();" class="button2" />			</td>

		  </tr>

			<?php

		}

			?>

</table>

</form>

<form action="<?=$url?>" method="post" name="pageform" id="pageform">

<table width="90%" border="0" align="center" cellpadding="10" cellspacing="0">

    <tr>

      <td height="30" align="center">

	  <?php

			if($news_nums > $pagesize){

				if ($pageval<=1){

					$pageval=1;

					echo "首页&nbsp;&nbsp;";

				}else{

					echo "<a href=".$url."page=1>首页</a>&nbsp;&nbsp;";

				}

					if ($pageval<=1){

					echo "上一页</a>&nbsp;&nbsp;";

					}else{

					echo "<a href=".$url."page=".($pageval-1).">上一页</a>&nbsp;&nbsp;";

					}

					

					if ($pageval>=$pagecount){

					echo "下一页&nbsp;&nbsp;";

					}else{

					echo "<a href=".$url."page=".($pageval+1).">下一页</a>&nbsp;&nbsp;";

					}

					if($pageval<$pagecount){

					echo "<a href=".$url."page=".$pagecount.">末页</a>&nbsp;&nbsp;";

					}else{

					echo "末页&nbsp;&nbsp;";

					}

					

					echo "共&nbsp;<font color='red'>".$news_nums."</font>&nbsp;条文章&nbsp;&nbsp;";

					echo "页次：<font color='red'>".$pageval."&nbsp;/&nbsp;</font>".$pagecount."&nbsp;页&nbsp;&nbsp;";

					echo "转到：<select name='page' onChange='javascript:document.pageform.submit()'>";

					for($i=1;$i<=$pagecount;$i++){

						if($i==$pageval){

							$selectval="selected";

						}

						echo "<option value=".$i." ".$selectval.">".$i."</option>";

						$selectval="";

					}

					echo "</select>";

						

			}

	?>

      </td>

    </tr>

</table>

</form>

</body>

</html>

